<template>
  <div class="user-avator-dropdown">
    <Dropdown @on-click="handleClick">
      <Avatar :src="userAvator"/>
      <Icon :size="18" type="md-arrow-dropdown"></Icon>
      <DropdownMenu slot="list">
        <DropdownItem name="logout">{{$t('m.tuìchūdēnglù')}}</DropdownItem>
      </DropdownMenu>
    </Dropdown>
  </div>
</template>

<script>
export default {
  name: 'User',
  props: {
    userAvator: {
      type: String,
      default: ''
    }
  },
  methods: {
    handleClick (name) {
      switch (name) {
        case 'logout':
          this.$http.post('/api/laocai/sys/account/logout')
          .then(()=>{
	      window.localStorage.removeItem("peacock");
          window.localStorage.removeItem("roles");
          window.localStorage.removeItem("account");
	          this.$router.push('/')
              }
          );
          break;

        default:
          break;
      }
    }
  }
}
</script>

<style lang="scss">
 @import "./user.scss";
</style>

